from flask import Flask, redirect, url_for
from flask import jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager

from flask_login import LoginManager

app = Flask(__name__)
app.config.from_object('config')
db = SQLAlchemy(app)

manager = Manager(app)
Migrate(app, db)
manager.add_command("db", MigrateCommand)

lm = LoginManager(app)

# 错误重定向
@app.errorhandler(500)
def err(staus):
    return jsonify(msg="小错误")

@app.errorhandler(404)
def err2(staus):
    return redirect(url_for("index_page.index"))


from app import view, models
